/*
 * 预警信息
 * *
 */

function remindInfo(layoutId,url,pageLimit) {

    var userId = antUtil.getSessionStorage('userId');
    var tokenId = antUtil.getSessionStorage('tokenId');

    //未读
    $.ajax({
        url: "/message/SearchMessageInfoByStatus",
        type: 'GET',
        dataType: "json",
        data: {
            tokenId: tokenId,
            userId: userId,
            status: '0'
        },
        success: function (data) {
            var html = '';
            var limit;
            var num = data.length;
            if (num < pageLimit - 1) {
                limit = num;
            } else {
                limit = pageLimit - 1;
            }
            for (var i = 0; i < limit; i++) {
                html += '<li><a href="#">' + data[i].title + '</a><span class="time">' + data[i].busiDate + '</span></li>';
            }

            $('#' + layoutId).find('.portletContent #mesRemain-list1').html(html);
        }
    })



    //已读
    $.ajax({
        url: "/message/SearchMessageInfoByStatus",
        type: 'GET',
        dataType: "json",
        data: {
            tokenId: tokenId,
            userId: userId,
            status: '1'
        },
        success: function (data) {
            var html = '';
            var limit;
            var num = data.length;
            if (num < pageLimit - 1) {
                limit = num;
            } else {
                limit = pageLimit - 1;
            }
            for (var i = 0; i < limit; i++) {
                html += '<li><a href="#">' + data[i].title + '</a><span class="time">' + data[i].busiDate + '</span></li>';
            }

            $('#' + layoutId).find('.portletContent #mesRemain-list2').html(html);
        }
    })
}

    /*
     * 流程追踪
     * *
     */

function flowTracing(layoutId,url,pageLimit){

    var userId = antUtil.getSessionStorage('userId');
    var nd = antUtil.getSessionStorage('nd');
    var tokenId = antUtil.getSessionStorage('tokenId');
    var JQurl1='http://192.168.0.90:9797/service?';
    var JQurl2='http://192.168.0.90:9797/bmjsworktodo?';
    var WZurl1='http://192.168.0.89:7005/bappr/services/WaitingImplServiceInfo?wsdl';
    //未办结
    $.ajax({
        url : "/flowTracing/getToDoFlowTracing",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            nd:nd,
            JQurl1:JQurl1,
            JQurl2:JQurl2,
            WZurl1:WZurl1,
            type:'1'
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><a href="#">'+data[i].name+'</a><span class="c money">'+data[i].number+'</span></li>';
            }

            $('#'+layoutId).find('.portletContent .process-list1').html(html);


            //详细
            $('.process-list1  li').click(function(){
                var url = $(this).attr('data-url');

                if(url.indexOf('http://')==-1 ){
                    url='http://'+url;
                }

                window.open(url, 'newwindow', 'width=' + screen.width + ',height=' + screen.height + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=n o, status=no');
            });


        }
    })


    //已办结
    $.ajax({
        url : "/flowTracing/getDoneFlowTracing",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            nd:nd,
            JQurl1:JQurl1,
            JQurl2:JQurl2,
            WZurl1:WZurl1,
            type:'2'
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><a href="#">'+data[i].name+'</a><span class="c money">'+data[i].number+'</span></li>';
            }

            $('#'+layoutId).find('.portletContent .process-list2').html(html);
        }
    })

}

/*
 * 待办查询
 * *
 */

function toDoList(layoutId,url,pageLimit){

var userId = antUtil.getSessionStorage('userId');
var nd = antUtil.getSessionStorage('nd');
var tokenId = antUtil.getSessionStorage('tokenId');

//清空待办dom
$('#'+layoutId).find('.portletContent ul').html('');

    var JQurl1='http://192.168.0.90:9797/service?';
    var JQurl2='http://192.168.0.90:9797/bmjsworktodo?';
    var WZurl1='http://192.168.0.89:7005/bappr/services/WaitingImplServiceInfo?wsdl';

//待办
    $.ajax({
        url : "/todoWork/getWorkTask",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            // roleId:'87135',
            JQurl1:JQurl1,
            JQurl2:JQurl2,
            WZurl1:WZurl1,
            type:'0',
            nd:nd
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><span class="icon-r"></span><a href="#">'+data[i].name+'</a><span class="count">'+data[i].number+'</span></li>';
            }

            $('#'+layoutId).find('.portletContent ul').append(html);
            //待办详细
            $('.toDoList ul li').click(function(){
                var url = $(this).attr('data-url');

                if(url.indexOf('http://')==-1 ){
                    url='http://'+url;
                }

                window.open(url, 'newwindow', 'width=' + screen.width + ',height=' + screen.height + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=yes,location=n o, status=no');
            });
        }
    })


//久其待办-部门决算
//     $.ajax({
//         url : "/service/getOutService",
//         type : 'GET',
//         dataType : "json",
//         async:false,
//         data : {
//             url:'http://192.168.0.90:9797/service?',
//             tokenId:tokenId,
//             userId:userId,
//             type:'0'
//         },
//         success : function(data) {
//             var html='';
//             var limit;
//             var num = data.length;
//             if(num < pageLimit-1){
//                 limit=num;
//             }else{
//                 limit=pageLimit-1;
//             }
//             for(var i=0;i<limit;i++){
//                 html+='<li data-url="'+data[i].url+'"><span class="icon-r"></span><a href="#">'+data[i].name+'</a><span class="count">'+data[i].number+'</span></li>';
//             }
//
//             $('#'+layoutId).find('.portletContent ul').append(html);
//                     //待办详细
//                     $('.toDoList ul li').click(function(){
//                         var url = $(this).attr('data-url');
//                         window.open('http://'+url);
//                     });
//         }
//     })
//
//
//
//
//
// //久其待办-统一报表
//         $.ajax({
//             url : "/service/getOutService",
//             type : 'GET',
//             dataType : "json",
//             data : {
//                 url:'http://192.168.0.90:9797/service?',
//                 tokenId:tokenId,
//                 userId:userId,
//                 type:'0'
//             },
//             success : function(data) {
//                 var html='';
//                 var limit;
//                 var num = data.length;
//                 if(num < pageLimit-1){
//                     limit=num;
//                 }else{
//                     limit=pageLimit-1;
//                 }
//                 for(var i=0;i<limit;i++){
//                     html+='<li data-url="'+data[i].url+'"><span class="icon-r"></span><a href="#">'+data[i].name+'</a><span class="count">'+data[i].number+'</span></li>';
//                 }
//
//                 $('#'+layoutId).find('.portletContent ul').append(html);
//                     //待办详细
//                     $('.toDoList ul li').click(function(){
//                         var url = $(this).attr('data-url');
//                         window.open('http://'+url);
//                     });
//             }
//         })

}

/*
 * 支出进度查询
 * *
 */

function accountPayment(layoutId,url,pageLimit) {

    var html = '<div class="topTable">';
        html+='<span class="budgetSpan">资金来源:</span>';
        html+='<select id="budgetSelect" class="budgetSelect">';
        html+='<option value="0">全部</option>';
        html+='<option value="1">基本支出</option>';
        html+='<option value="2">项目支出</option>';
        html+='<option value="3">政府采购</option>';
        html+='<option value="4">公务卡</option>';
        html+='</select>';
        html+='</div>';
        html+='<div class="topTable">';
        html+='<span >指标金额 :<span class="moneyNum">30,000.00</span></span>';
        html+='<span >支付金额 :<span class="moneyNum">10,000.00</span></span>';
        html+='<span >指标余额 :<span class="moneyNum">20,000.00</span></span>';
        html+='</div>';
        html+='<div id="accountPaymentTable" style="width:100%;height:150px;"></div>';

    $('#'+layoutId).html(html);

	var jsonSeries;
				jsonSeries = [{
				name: '指标金额',
				data: [350]
			}, {
				name: '支付金额',
				data: [10]
			}, {
				name: '指标余额',
				data: [150]
			}

		];

	//单位支出
	$('#accountPaymentTable').highcharts({
		chart: {
			type: 'bar'
		},
		credits: {
			enabled: false
		},
		exporting: {
			enabled: false
		},
		title: {
			text: ''
		},
		xAxis: {　　
			
			labels: {
				enabled: true
			},
			tickWidth: 0,
			categories: ['']
		},
		yAxis: {
			min: 0,
			title: {
				text: ''
			},
			opposite:true,
			labels: { //y轴刻度文字标签  
				formatter: function() {
					return this.value + '%'; //y轴加上%  
				}
			},
　　plotLines: [{   //一条延伸到整个绘图区的线，标志着轴中一个特定值。
                    color: 'red',
                    dashStyle: 'Dash', //Dash,Dot,Solid,默认Solid
                    width: 3,
                    value: 55,  //y轴显示位置
                    zIndex: 5,
                    label: {
			                text: '<span style="color:red">▲   <span><div><span style="color:red">'+56+'%</span></div>',//+xsjd+'%',//xsjd+'%',
			                align: 'left',
			                rotation: 0,
			                x: -9,
			                y: 80,
			                style: {
			                    'color': 'red',
			                    'fontWeight': 'bold',
			                    'font-size': '20px',
			                    'cursor': 'default'
			                }
			            },
                }]
		},
		tooltip: {
			pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y} (万元)</b> ({point.percentage:.0f}%)<br/>',
			shared: false,
			split: true
		},
		colors: ['#D3EBFD','#3448A1','#F66902'],
		legend: {
			reversed: true,
			layout: 'horizontal',
			align: 'center',
			verticalAlign: 'top',
			x: 200,
			y: -10,
			floating: false,
			borderWidth: 0,
			backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
			shadow: false
		},
		plotOptions: {
			series: {
				stacking: 'percent',
				dataLabels: {
					enabled: true,
					color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
					style: {
						textShadow: '0 0 3px green'
					},
					formatter: function() {
						return this.point.percentage.toFixed(1) + '%';
						

					}
				},
				events: {
					click: function(event) {
//						console.log(event.point.category);
//						console.log(event.point.y);
//						console.log(event.point.series.name);
//						//				location.href = url;
//						//上面是当前页跳转，如果是要跳出新页面，那就用
//						//支付状态
//						var zfzt = event.point.series.name;
//						if(zfzt == '已支付') {
//							window.open('https://www.baidu.com');
//						} else if(zfzt == '在途支付') {
//							window.open('http://www.iqiyi.com/')
//						} else if(zfzt == '可用额度') {
//							window.open('http://www.yonyou.com/index.html')
//						}
//						//              window.open(e.point.url);
					}
				}
			}
		},
		series: jsonSeries
	});
};

